<?php
/**
 * Core_Data_Allmoduledata
 * get all module data
 * @author Adrian Stolarski
 */
class Core_Data_Allmodulesdata implements Core_Data_Mainable, 
        Core_Data_Preparable {
    
    /**
     *
     * @var type $database
     * database handler
     */
    public $database;
    /**
     *
     * @var type $database_query
     * database query handler
     */
    public $database_query;
    
    /**
     * constructor()
     */
    public function __construct() {
        $this->database = new Core_Driver_MysqlImproved();
    }
    
    
    public function main(array $variables = null) {
        $this->database->connect();
        //var_dump($variables);
        //die();
        $this->prepare_query($variables);
        //echo $this->database_query;
        //die();
        $this->database->prepare($this->database_query);
        $this->database->query();
        $modules_data = array();
        while($module_data = $this->database->fetch('array')){
            $modules_data[$module_data['module_name']] = $module_data;
        }
        //var_dump($modules_data);
        //die();
        return $modules_data;
    }
    
    /**
     * preapre_query()
     * prepare database query
     * 
     * @param array $variables
     */
    public function prepare_query(array $variables = null) {
        $this->database_query = "SELECT * FROM page_module ORDER BY module_name ASC;";
    }

}
